import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import routes from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueAMap from 'vue-amap';
import './public-path'
Vue.use(VueRouter)
Vue.use(ElementUI)
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
  key: '80d0aaf80f6997c9abb96c5363880d2e',
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
});
Vue.config.productionTip = false

let instance = null;
let router = null;
//single-spa的生命周期函数
export async function bootstrap({ fns = [] } = {}) {
  Array.isArray(fns) && fns.map(i => {
    Vue.prototype[i.name] = i
  });
}

export async function mount(props) {
  console.log(props)
  router = new VueRouter({
    base: window.__POWERED_BY_QIANKUN__ ? '/app1' : '/',
    mode: 'history',
    routes
  })
  instance = new Vue({
    router,
    render: h => h(App)
  }).$mount("#app1");

}

export async function unmount() {
  instance.$destroy();
  instance = null;
  router = null;
}

console.log(window.__POWERED_BY_QIANKUN__)
// 单独开发环境
window.__POWERED_BY_QIANKUN__ || mount();